package com.example.boot.rabbitmq.producer.rest;

import com.example.boot.rabbitmq.producer.config.RabbitProperties;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 *  死信队列
 * @author root
 * @date 2021-03-06 13:18
 */
@RestController
@RequiredArgsConstructor
public class DlxRest {

    private final RabbitTemplate rabbitTemplate;
    private final RabbitProperties rabbitProperties;

    @GetMapping("dlx")
    public String dlx() {
        rabbitTemplate.convertAndSend(rabbitProperties.getExchangeNormal(), rabbitProperties.getDlxKey(), "dlx");
        return "ok";
    }

    @GetMapping("dlxTopic")
    public String dlxTopic() {
        rabbitTemplate.convertAndSend(rabbitProperties.getExchangeTopic(), rabbitProperties.getSendOrderKey(), "dlxTopic");
        return "ok";
    }
}
